// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/equipment/api/AssetOperateApi'

import SubmitClass from '@api/equipment/model/AssetOperateApplyReq'
import HosUseful from '@api/equipment/model/HosUseful'
import HosError from '@api/equipment/model/HosError'
import HosStop from '@api/equipment/model/HosStop'
import HosIdle from '@api/equipment/model/HosIdle'
import HosDeal from '@api/equipment/model/HosDeal'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 提交 —————————————————————————————— //

  async submit(one, TIP = '操作') {
    let BASE
    if (one.operateType === 5) BASE = [HosUseful, 'hosUseful']
    if (one.operateType === 6) BASE = [HosError, 'hosError']
    if (one.operateType === 7) BASE = [HosStop, 'hosStop']
    if (one.operateType === 8) BASE = [HosIdle, 'hosIdle']
    if (one.operateType === 9) BASE = [HosDeal, 'hosDeal']

    const DTO = CORE.grpcDTO(SubmitClass, one, BASE)
    await CORE.grpc(TIP, CLIENT, 'assetOperateApply', DTO)
    return CORE.grpcOK(TIP)
  },
}
